home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.4)
-
- '''
- Setup logging.
-
- This is the very first thing that we do, so we maximise the chances of
- getting errors to the log file. All that we require are that os and sys
- can be imported, which will only fail if the Python install is really
- stuffed (these are both actually built into Python). If tempfile can
- also be imported (this should always be the case), then the temp
- directory is used as location; otherwise the current working directory
- is used. If running in a console on Windows with pywin32 available, we
- leave output as-is.
-
- This file must be kept as simple as possible, and should only include
- imports from the core Python distribution. Imports are left as late
- as possible.
- '''
-
- try:
- import tempfile
- except ImportError:
- log_dir = ''
-
- log_dir = tempfile.gettempdir()
- _setup_complete = False
-
- def setup(log_name = 'SpamExperts', rollover_count = 4):
- global _setup_complete
- if _setup_complete:
- return None
-
-
- try:
- import win32api
- win32api.GetConsoleTitle()
- except:
- import os
- for i in range(rollover_count - 1, 0, -1):
-
- try:
- os.unlink(os.path.join(log_dir, '%s%d.log' % (log_name, i + 1)))
- except os.error:
- pass
-
-
- try:
- os.rename(os.path.join(log_dir, '%s%d.log' % (log_name, i)), os.path.join(log_dir, '%s%d.log' % (log_name, i + 1)))
- continue
- except os.error:
- continue
-
-
-
- import sys
- stdout = sys.stdout
- stderr = sys.stderr
- sys.stdout = open(os.path.join(log_dir, '%s1.log' % (log_name,)), 'wt', 0)
- sys.stderr = sys.stdout
-
- try:
- stdout.seek(0)
- print stdout.read()
- stderr.seek(0)
- print stderr.read()
-
-
- _setup_complete = True
-
-